Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  get '/docs/index', to: 'docs#index'
  # api v1 路由设置
  namespace :api do
    namespace :v1 do
      scope path: '/user/:user_id' do
         resources :microposts, only: [:index]
      end
      resources :sessions, only: [:create]
      resources :users, only: [:index, :create, :show, :update, :destroy]
      # 原文有 microposts, 我们现在把它注释掉
      # resources :microposts, only: [:index, :create, :show, :update, :destroy]
    end

    # api v2 路由设置
    namespace :v2 do
      resources :users, only: [:index, :create, :show, :update, :destroy]
      resources :sessions, only: [:create]
      scope path: '/user/:user_id' do
        resources :microposts, only: [:index]
      end
    end

  end

end
